package com.example.tests;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.not;

import java.util.Random;

import org.testng.annotations.Test;

import com.example.fw.GroupHelper;
import com.example.fw.Groups;


	public class GroupModificationTests extends TestBase {

		@Test(dataProvider = "randomGroups")
	    public void testFirstGroupCanBeRemoved(GroupObject validGroup) throws Exception {
	            GroupHelper groupHelper = app.getGroupHelper();
	            Groups oldList = app.getGroupHelper().getGroups();
	            if (oldList.size() == 0) {
	            	 int index = new Random().nextInt(oldList.size());
	                 GroupObject groupModification = groupHelper.getGroup(groupHelper.checkGroup(index));
	                 groupHelper.modifyGroup(index, validGroup);
	                 GroupObject groupChangeModification = groupHelper.getGroup(groupHelper.checkGroup(index));
	                 Groups newList = app.getGroupHelper().getGroups();
	                 assertThat(newList, equalTo(oldList.without(groupModification.withAdded(groupChangeModification))));
	         }


		}
}